/* eslint-disable consistent-return */
/* eslint-disable jsx-a11y/alt-text */
/* eslint-disable no-param-reassign */
/* eslint-disable array-callback-return */
/* eslint-disable eqeqeq */
import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import {
  DownloadOutlined,
  DownOutlined,
  UpOutlined,
  QuestionCircleOutlined,
} from '@ant-design/icons';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import {
  Row,
  Col,
  Card,
  Input,
  Button,
  Dropdown,
  Menu,
  Modal,
  message,
  Badge,
  Divider,
  DatePicker,
  Tabs,
  Select,
  Alert,
  Radio,
  Tooltip,
  Cascader,
} from 'antd';
import Link from 'umi/link';

import router from 'umi/router';
import moment from 'moment';
import _ from 'lodash';
import queryString from 'query-string';
import StandardTable from '@/components/StandardTable';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import ProTable from '@/pages/components/Problem/ProblemPage/ProTable';
import ProExportBtn from '@/pages/components/Problem/ProblemPage/ProExportBtn';
import ProModal from '@/pages/components/Problem/ProblemPage/ProModal';
import Authorized from '@/utils/Authorized';
import styles from '@/utils/utils.less';
import downloadFile, { getProPagination } from '@/utils/utils';
import { checkPermissions } from '@/utils/authority';
import TextOverFlow from '../../components/TextOverFlow';
import proIcon from '../../../assets/proIcon.png';
import Area from '../../components/Area';
import BatchTaskProgress from '../../components/BatchTaskProgress';

const RadioGroup = Radio.Group;
const FormItem = Form.Item;
const { Option } = Select;
const { TabPane } = Tabs;
const { RangePicker } = DatePicker;
const RadioButton = Radio.Button;
const { TextArea } = Input;

@connect(({ addemprec, loading }) => ({
  data: addemprec.data,
  proData: addemprec.proData,
  supplyList: addemprec.supplyList,
  dataInfo: addemprec.detail || {},
  loading:
    loading.effects['addemprec/getBatchId'] ||
    loading.effects['addemprec/getProgress'] ||
    loading.effects['addemprec/getcustNamesList'] ||
    loading.effects['addemprec/uploadFileWithProgress']
      ? false
      : loading.models.addemprec,
  cancelReceiveLoading: loading.effects['addemprec/cancelReceive'],
  addemprec,
  custList: addemprec.custList,
  expandForm: addemprec.expandForm,
  formFieldsValue: addemprec.formFieldsValue,
  activeKey: addemprec.activeKey,
  tabList: addemprec.tabList,
  injAccList: addemprec.injAccList,
  allInjAccList: addemprec.allInjAccList,
  injAccParams: addemprec.injAccParams,
  downloadParams: addemprec.downloadParams,
}))
@Form.create()
class TableList extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      formValues: {},
      selectedRows: [],
      selectedRowKeys: [],
      editFlag: null, // 状态
      cancelReceiveVisible: false, // 取消接单办理备注
      receiveModal: false,
      proTable: {},
      proVisible: false,
    };
    this.tableSearchLayout = {
      labelCol: { md: { span: 5 } },
      wrapperCol: { md: { span: 17 } },
    };

    this.columns = [
      {
        title: '姓名',
        dataIndex: 'empName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: (text, record) =>
          record.probFlag == 1 ? (
            <Tooltip
              placement="top"
              title={
                <div>
                  <p>
                    问题人员类型：
                    {record.probDets && record.probDets[0] ? record.probDets[0].probTypeName : '--'}
                  </p>
                  <p>
                    问题说明：
                    {record.probDets && record.probDets[0] ? record.probDets[0].probTypeDesc : '--'}
                  </p>
                </div>
              }
            >
              <span>
                {text}
                <img src={proIcon} />
              </span>
            </Tooltip>
          ) : (
            <span>{text}</span>
          ),
      },
      {
        title: '客户名称',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'custName',
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '执行地区',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'cityName',
      },

      {
        title: '协议名称',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'suppProtName',
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '签约方',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'sendSuppName',
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '任务类型',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'taskSourceName',
      },

      {
        title: '发单时间',
        dataIndex: 'sendTime',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        sorter: (a, b) => new Date(b.sendTime) - new Date(a.sendTime),
        render: val => (val && moment(val).format('YYYY-MM-DD HH:mm')) || '--',
      },
      {
        title: '操作',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', width: 150, textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'center' } }),
        render: (text, record) => (
          <Link
            to={`/receiveordermanage/addemployee/detail?recvOrdAddTaskId=${
              record.recvOrdAddTaskId
            }`}
          >
            查看
          </Link>
        ),
      },
    ];
    this.columnstwo = [
      {
        title: '姓名',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'empName',
        render: (text, record) =>
          record.probFlag == 1 ? (
            <Tooltip
              placement="top"
              title={
                <div>
                  <p>
                    问题人员类型：
                    {record.probDets && record.probDets[0] ? record.probDets[0].probTypeName : '--'}
                  </p>
                  <p>
                    问题说明：
                    {record.probDets && record.probDets[0] ? record.probDets[0].probTypeDesc : '--'}
                  </p>
                </div>
              }
            >
              <span>
                {text}
                <img src={proIcon} />
              </span>
            </Tooltip>
          ) : (
            <span>{text}</span>
          ),
      },
      {
        title: '证件号',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'idCode',
      },
      {
        title: '客户名称',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'custName',
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '执行地区',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'cityName',
      },
      {
        title: '联系进度',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'hdlStatusName',
      },
      {
        title: '签约方',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'sendSuppName',
        render: text => <TextOverFlow text={text} />,
      },

      {
        title: '协议名称',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'suppProtName',
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '任务类型',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'taskSourceName',
      },

      {
        title: '接单时间',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'sendTime',
        sorter: (a, b) => new Date(b.sendTime) - new Date(a.sendTime),
        render: val => (val && moment(val).format('YYYY-MM-DD HH:mm')) || '--',
      },
      {
        title: '操作',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', width: 150, textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'center' } }),
        render: (text, record) => (
          <div>
            <Link
              to={`/receiveordermanage/addemployee/detail?recvOrdAddTaskId=${
                record.recvOrdAddTaskId
                // eslint-disable-next-line react/destructuring-assignment
              }&activeKey=${this.props.activeKey}`}
            >
              查看
            </Link>
            <Authorized authority="ns:recvAdd:recvOrdInfo:get:byTaskId" noMatch={null}>
              <Divider type="vertical" />
              <a onClick={() => this.orderreceipt(1, record)}>修改</a>
            </Authorized>
          </div>
        ),
      },
    ];
    this.columnsthree = [
      {
        title: '姓名',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'empName',
        render: (text, record) =>
          record.probFlag == 1 ? (
            <Tooltip
              placement="top"
              title={
                <div>
                  <p>
                    问题人员类型：
                    {record.probDets && record.probDets[0] ? record.probDets[0].probTypeName : '--'}
                  </p>
                  <p>
                    问题说明：
                    {record.probDets && record.probDets[0] ? record.probDets[0].probTypeDesc : '--'}
                  </p>
                </div>
              }
            >
              <span>
                {text}
                <img src={proIcon} />
              </span>
            </Tooltip>
          ) : (
            <span>{text}</span>
          ),
      },
      {
        title: '客户名称',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'custName',
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '执行地区',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'cityName',
      },
      {
        title: '签约方',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'sendSuppName',
        render: text => <TextOverFlow text={text} />,
      },

      {
        title: '协议名称',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'suppProtName',
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '任务类型',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'taskSourceName',
      },
      {
        title: '有无修改',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'editFlagName',
      },

      {
        title: '回单时间',
        dataIndex: 'returnTime',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        sorter: (a, b) => new Date(b.returnTime) - new Date(a.returnTime),
        render: val => (val && moment(val).format('YYYY-MM-DD HH:mm')) || '--',
      },
      {
        title: '操作',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', width: 150, textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'center' } }),
        render: (text, record) => (
          <Fragment>
            <Link
              to={`/receiveordermanage/addemployee/detail?recvOrdAddTaskId=${
                record.recvOrdAddTaskId
                // eslint-disable-next-line react/destructuring-assignment
              }&activeKey=${this.props.activeKey}`}
            >
              查看
            </Link>
            <Authorized authority="ns:recvAdd:cancel:return" noMatch={null}>
              <Divider type="vertical" />
              <a
                onClick={() => {
                  this.cancelReceipt(record, record.recvOrdAddTaskId);
                }}
              >
                取消回单
              </a>
            </Authorized>
          </Fragment>
        ),
      },
    ];
    // this.columnsfour = [
    //   {
    //     title: '姓名',
    //     onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
    //     dataIndex: 'empName',
    //   },
    //   {
    //     title: '证件号',
    //     onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
    //     dataIndex: 'idCode',
    //   },
    //   {
    //     title: '客户名称',
    //     onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
    //     dataIndex: 'custName',
    //     render: text => <TextOverFlow text={text} />,
    //   },
    //   {
    //     title: '签约方',
    //     onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
    //     dataIndex: 'sendSuppName',
    //     render: text => <TextOverFlow text={text} />,
    //   },

    //   {
    //     title: '问题对象',
    //     onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
    //     dataIndex: 'probObj',
    //   },

    //   {
    //     title: '问题类型',
    //     onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
    //     dataIndex: 'probTypeIdName',
    //   },
    //   {
    //     title: '是否通知',
    //     onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
    //     dataIndex: 'sendSuppFlagName',
    //   },
    //   {
    //     title: '操作',
    //     onHeaderCell: () => ({ style: { fontWeight: 'bold', width: 150, textAlign: 'center' } }),
    //     onCell: () => ({ style: { textAlign: 'center' } }),
    //     render: (text, record) => (
    //       <Link to={`/receiveordermanage/addemployee/problemdetail?detId=${record.detId}`}>
    //         查看
    //       </Link>
    //     ),
    //   },
    // ];
    this.columnsfive = [
      {
        title: '姓名',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'empName',
        render: (text, record) =>
          record.probFlag == 1 ? (
            <Tooltip
              placement="top"
              title={
                <div>
                  <p>
                    问题人员类型：
                    {record.probDets && record.probDets[0] ? record.probDets[0].probTypeName : '--'}
                  </p>
                  <p>
                    问题说明：
                    {record.probDets && record.probDets[0] ? record.probDets[0].probTypeDesc : '--'}
                  </p>
                </div>
              }
            >
              <span>
                {text}
                <img src={proIcon} />
              </span>
            </Tooltip>
          ) : (
            <span>{text}</span>
          ),
      },
      {
        title: '客户名称',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'custName',
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '执行地区',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'cityName',
      },
      {
        title: '签约方',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'sendSuppName',
        render: text => <TextOverFlow text={text} />,
      },
      {
        title: '协议名称',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'suppProtName',
        render: text => <TextOverFlow text={text} />,
      },

      {
        title: '任务类型',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'taskSourceName',
      },
      {
        title: '取消时间',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        dataIndex: 'cancelTime',
        sorter: true,
        render: val => (val && moment(val).format('YYYY-MM-DD HH:mm')) || '--',
      },
      {
        title: '操作',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', width: 150, textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'center' } }),
        render: (text, record) => (
          <Link
            to={`/receiveordermanage/addemployee/detail?recvOrdAddTaskId=${
              record.recvOrdAddTaskId
            }`}
          >
            查看
          </Link>
        ),
      },
    ];
  }

  componentDidMount() {
    const {
      location,
      activeKey,
      dispatch,
      data: { pagination },
      params,
    } = this.props;
    const { isMenuLink } = queryString.parse(location.search);
    const tempActiveKey = queryString.parse(location.search).activeKey || activeKey;
    dispatch({
      type: 'addemprec/updateModelData',
      payload: {
        activeKey: tempActiveKey,
        selectedData: [],
        proBaseList: {},
        proFbList: [],
      },
    });
    const proPagination = getProPagination(tempActiveKey, '4', pagination);
    if (isMenuLink) {
      this.resetAndGeLlist(location);
    } else {
      this.getList(tempActiveKey, proPagination.current, proPagination.pageSize);
    }
    // this.getList();
    this.getCustList(null);
    dispatch({
      type: 'addemprec/fetchSupplyList',
      payload: { name: null, ...params },
    });
  }

  componentWillUnmount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'addemprec/updateModelData',
      payload: { progressPercent: 0 },
    });
  }

  // 查看当前有无任务
  checkHasTask = () => {
    const { dispatch } = this.props;
    // 查看当前有无任务进行
    dispatch({
      type: 'addemprec/checkHasTask',
    });
  };

  // 进度弹框显隐
  handleProgressModalVisible = flag => {
    const {
      activeKey,
      data: { pagination },
      dispatch,
    } = this.props;
    if (!flag) {
      dispatch({
        type: 'addemprec/updateModelData',
        payload: {
          showProgress: false,
        },
      });
      this.getList(activeKey, pagination.current, pagination.pageSize);
    }
  };

  // 获取客户的下拉
  getCustList = e => {
    const { dispatch } = this.props;
    dispatch({
      type: 'addemprec/getcustNamesList',
      payload: {
        suppId: e,
      },
    });
  };

  getsuppId = e => {
    const { dispatch } = this.props;
    dispatch({
      type: 'addemprec/updateModelData',
      payload: {
        custList: [],
      },
    });
    const { supplyList, form } = this.props;
    form.resetFields(['custId']);
    supplyList.map(item => {
      if (item.suppId == e) {
        this.getCustList(item.suppId);
      }
      return true;
    });
  };

  // 获取列表
  getList = (activeKey = '1', currentPage = 1, pageSize = 10, queryParam, isClear = true) => {
    if (isClear) {
      this.setState({ selectedRows: [], selectedRowKeys: [] });
    }
    const { dispatch, form } = this.props;

    const { editFlag } = this.state;
    form.validateFields((err, fieldsValue) => {
      delete fieldsValue.remark;
      if (err) return;
      // fieldsValue = queryParam || fieldsValue;
      dispatch({
        type: 'addemprec/updateModelData',
        payload: {
          formFieldsValue: fieldsValue,
          activeKey,
        },
      });
      const formFieldsValue = {};
      // eslint-disable-next-line no-restricted-syntax
      for (const key in fieldsValue) {
        if (key == 'createTime') {
          formFieldsValue.operTimeStart =
            (fieldsValue.createTime &&
              fieldsValue.createTime[0] &&
              fieldsValue.createTime[0].format('YYYY-MM-DD')) ||
            null;
          formFieldsValue.operTimeEnd =
            (fieldsValue.createTime &&
              fieldsValue.createTime[1] &&
              fieldsValue.createTime[1].format('YYYY-MM-DD')) ||
            null;
        } else if (key === 'empName' || key === 'idCode') {
          formFieldsValue[key] = (fieldsValue[key] && fieldsValue[key].trim()) || null;
        } else if (fieldsValue[key] && fieldsValue[key].key) {
          formFieldsValue[key] =
            fieldsValue[key].key === undefined ? undefined : fieldsValue[key].key;
        } else {
          formFieldsValue[key] = fieldsValue[key] === undefined ? undefined : fieldsValue[key];
        }
      }
      let newvalues = {};
      if (formFieldsValue.createTime == null) {
        newvalues = {
          sendSuppId: formFieldsValue.sendSuppId,
          cityId: formFieldsValue.cityId,
          custId: formFieldsValue.custId,
          empName: formFieldsValue.empName,
          idCode: formFieldsValue.idCode,
          // createTime: formFieldsValue.createTime,
          operTimeStart:
            (fieldsValue.createTime &&
              fieldsValue.createTime[0] &&
              fieldsValue.createTime[0].format('YYYY-MM-DD')) ||
            null,
          operTimeEnd:
            (fieldsValue.createTime &&
              fieldsValue.createTime[1] &&
              fieldsValue.createTime[1].format('YYYY-MM-DD')) ||
            null,
        };
      } else {
        newvalues = {
          sendSuppId: formFieldsValue.sendSuppId,
          cityId: formFieldsValue.cityId,
        };
      }

      const pageArg = { currentPage, pageSize };
      const values = {
        ...newvalues,
        pageArg,
        hdlState: activeKey,
        editFlag,
      };

      const downloadParams = {
        ...newvalues,
        busiType: 8,
        editFlag,
      };
      dispatch({
        type: 'addemprec/updateModelData',
        payload: {
          downloadParams,
        },
      });
      if (activeKey && Number(activeKey) === 4) {
        setTimeout(() => {
          const { proTable } = this.state;
          const proFormFieldsValue = { ...downloadParams };
          if (proTable.searchList) {
            proTable.searchList(proFormFieldsValue, currentPage, pageSize);
          }
        });
      } else {
        dispatch({
          type: 'addemprec/fetchList',
          payload: values,
        });
      }

      // if (activeKey === '4') {
      //   dispatch({
      //     type: 'addemprec/fetchProList',
      //     payload: {
      //       ...newvalues,
      //       pageArg,
      //       busiType: 1,
      //     },
      //   });
      // } else {
      //   dispatch({
      //     type: 'addemprec/fetchList',
      //     payload: values,
      //   });
      // }
      this.setState({
        formValues: newvalues,
      });
    });
  };

  handleSearch = (activeKey, currentPage = 1, pageSize = 10) => {
    const { dispatch, form, tabList } = this.props;
    const { editFlag } = this.state;
    const newTabList = tabList.map(item => ({ ...item, isHas: false }));
    dispatch({
      type: 'addemprec/updateModelData',
      payload: { tabList: newTabList },
    });
    const formFieldsValue = {};
    form.validateFields((err, fieldsValue) => {
      if (err) return;
      Object.keys(fieldsValue).forEach(key => {
        if (key === 'empName' || key === 'idCode') {
          fieldsValue[key] = (fieldsValue[key] && fieldsValue[key].trim()) || null;
        }
        if (key == 'createTime') {
          formFieldsValue.operTimeStart =
            (fieldsValue.createTime &&
              fieldsValue.createTime[0] &&
              fieldsValue.createTime[0].format('YYYY-MM-DD')) ||
            null;
          formFieldsValue.operTimeEnd =
            (fieldsValue.createTime &&
              fieldsValue.createTime[1] &&
              fieldsValue.createTime[1].format('YYYY-MM-DD')) ||
            null;
        }
        if (fieldsValue[key] && fieldsValue[key].key) {
          formFieldsValue[key] =
            fieldsValue[key].key === undefined ? undefined : fieldsValue[key].key;
        } else {
          formFieldsValue[key] = fieldsValue[key] === undefined ? undefined : fieldsValue[key];
        }
        delete formFieldsValue.operTime;
      });

      const checkHasValue = Object.keys(fieldsValue).some(
        key => Boolean(fieldsValue[key]) !== false
      );
      dispatch({
        type: 'addemprec/updateTabListQuery',
        payload: { formFieldsValue, activeKey },
      });

      const formFieldsValues = {};
      // eslint-disable-next-line no-restricted-syntax
      for (const key in fieldsValue) {
        if (key == 'createTime') {
          formFieldsValues.operTimeStart =
            (fieldsValue.createTime &&
              fieldsValue.createTime[0] &&
              fieldsValue.createTime[0].format('YYYY-MM-DD')) ||
            null;
          formFieldsValues.operTimeEnd =
            (fieldsValue.createTime &&
              fieldsValue.createTime[1] &&
              fieldsValue.createTime[1].format('YYYY-MM-DD')) ||
            null;
        } else if (fieldsValue[key] && fieldsValue[key].key) {
          formFieldsValues[key] =
            fieldsValue[key].key === undefined ? undefined : fieldsValue[key].key;
        } else {
          formFieldsValues[key] = fieldsValue[key] === undefined ? undefined : fieldsValue[key];
        }
      }

      this.setState({ selectedRowKeys: [], selectedRows: [] });
      const values = {
        ...formFieldsValues,
      };
      this.setState({
        formValues: values,
      });
      if (activeKey === '4') {
        const downloadParams = {
          ...formFieldsValues,
          busiType: 8,
          editFlag,
        };
        dispatch({
          type: 'addemprec/updateModelData',
          payload: {
            downloadParams,
          },
        });
      }
      if (checkHasValue) {
        dispatch({
          type: 'addemprec/fetchTabNum',
          payload: { formFieldsValue: values, currentPage, pageSize },
        });
      } else {
        this.getList(activeKey, currentPage, pageSize);
      }
    });
  };

  // 重置
  handleFormReset = () => {
    const { form, dispatch } = this.props;
    dispatch({
      type: 'addemprec/updateModelData',
      payload: {
        formFieldsValue: {},
        custList: [],
      },
    });
    form.resetFields();
    form.setFieldsValue({ createTime: null });
  };

  // 标记问题人员确定
  proHandleOk = () => {
    const { activeKey } = this.props;
    this.toggleProModal(false);
    this.handleSearch(activeKey);
  };

  // 切换表格展开收起
  toggleForm = () => {
    const { dispatch, expandForm } = this.props;
    dispatch({
      type: 'addemprec/updateModelData',
      payload: {
        expandForm: !expandForm,
      },
    });
  };

  // 点击复选框
  handleSelectRows = (selectedRows, selectedRowKeys) => {
    this.setState({
      selectedRows,
      selectedRowKeys,
    });
  };

  // 有无修改
  saculo = e => {
    e.preventDefault();
    const hadlel = e == null ? null : e.target.value;
    this.setState(
      {
        editFlag: hadlel,
      },
      () => {
        this.getList('3');
      }
    );
  };

  // 导出
  export = () => {
    const { selectedRowKeys } = this.state;
    if (!selectedRowKeys.length) {
      Modal.confirm({
        icon: <QuestionCircleOutlined />,
        title: '温馨提示',
        content: '如果不选择列表数据，则默认导出当前条件下所有数据',
        okText: '导出',
        cancelText: '取消',
        onOk: () => {
          this.exportExcel();
        },
      });
    } else {
      this.exportExcel();
    }
  };

  // 导出excel
  exportExcel = () => {
    const { activeKey } = this.props;
    const { formValues, selectedRowKeys } = this.state;
    delete formValues.pageArg;
    if (activeKey === '4') {
      // 问题人员
      const pames = {
        detIds: (selectedRowKeys.length && selectedRowKeys) || null,
        hdlState: activeKey,
        ...formValues,
        busiType: 1,
      };
      downloadFile(pames, '/nsApi/recvProb/export', 'POST');
    } else {
      const pames = {
        recvAddTaskIds: (selectedRowKeys.length && selectedRowKeys) || null,
        hdlState: activeKey,
        busiType: 1,
        ...formValues,
      };
      downloadFile(pames, '/nsApi/recvAdd/recvd/export', 'POST');
    }
  };

  // 通知签约方
  // notifycontg = () => {
  //   const { dispatch } = this.props;
  //   const { selectedRowKeys } = this.state;
  //   const parmes = {
  //     busiType: 1,
  //     detIds: selectedRowKeys,
  //   };

  //   if (selectedRowKeys.length) {
  //     dispatch({
  //       type: 'addemprec/notifyc',
  //       payload: parmes,
  //       callback: response => {
  //         if (response.success) {
  //           message.success('通知成功');
  //           this.getList('4');
  //         } else {
  //           message.warning('通知失败');
  //           this.getList('4');
  //         }
  //       },
  //     });
  //   } else {
  //     message.warning('请至少选择一项！');
  //   }
  // };

  // 取消回单
  cancelReceipt = (record, recvOrdAddTaskId) => {
    this.handleSelectRows([record], [recvOrdAddTaskId]);
    Modal.confirm({
      icon: <QuestionCircleOutlined />,
      title: '取消回单',
      content: '确认要取消回单吗？',
      okText: '确认',
      cancelText: '取消',
      onOk: () => {
        router.push(
          `/receiveordermanage/addemployee/cancelreceipt?recvOrdAddTaskId=${recvOrdAddTaskId}`
        );
      },
    });
  };

  // 员工联系
  employeecontact = () => {
    const { selectedRowKeys, selectedRows } = this.state;
    if (selectedRowKeys.length > 1) {
      message.warning('只能选择一项！');
    } else if (selectedRows.length === 0) {
      message.warning('请选择一项！');
    } else {
      router.push(
        `/receiveordermanage/addemployee/employeecontact?recvOrdAddTaskId=${
          selectedRowKeys[0]
        }&&areaId=${selectedRows[0].cityId}`
      );
    }
  };

  // 回单
  orderreceipt = (e, record) => {
    const { selectedRowKeys } = this.state;
    const {
      dispatch,
      activeKey,
      data: { pagination },
    } = this.props;
    const route = e === 1 ? 'update' : 'receipt';
    if (record) {
      router.push(
        `/receiveordermanage/addemployee/${route}?recvOrdAddTaskId=${
          record.recvOrdAddTaskId
        }&isModify=${e}`
      );
    } else if (selectedRowKeys.length == 1) {
      router.push(
        `/receiveordermanage/addemployee/${route}?recvOrdAddTaskId=${
          selectedRowKeys[0]
        }&isModify=${e}`
      );
    } else if (selectedRowKeys.length > 1) {
      dispatch({
        type: 'addempreceiptrec/receiptId',
        payload: {
          recvOrdAddTaskId: selectedRowKeys,
        },
        callback: response => {
          if (response.success == true) {
            message.success('回单成功！');
            this.getList(activeKey, pagination.current, pagination.pageSize);
          } else {
            message.warning(response.message || '回单失败!');
          }
        },
      });
    } else {
      message.warning('请选择一项进行回单');
    }
  };

  // 标记问题人员Modal显示隐藏
  showModal = flag => {
    const { form } = this.props;
    const { selectedRows } = this.state;
    form.resetFields();
    if (selectedRows.length) {
      this.setState({
        proVisible: flag,
      });
    } else {
      message.warning('请至少选择一项');
    }
  };

  // 标记问题人员取消
  toggleProModal = flag => {
    this.setState({
      proVisible: flag,
    });
  };

  // 接单:判断是否选择数据
  receiveOrder = () => {
    const { selectedRowKeys } = this.state;
    if (selectedRowKeys.length) {
      this.getTaskOrinjAcc();
    } else {
      Modal.confirm({
        icon: <QuestionCircleOutlined />,
        title: '温馨提示',
        content: '没有选择数据，默认将查询条件下可自动接单的数据接单，是否确定？',
        okText: '确定',
        cancelText: '取消',
        onOk: () => {
          this.getTaskOrinjAcc();
        },
      });
    }
  };

  // 接单:获取任务或者工伤二级户列表
  getTaskOrinjAcc = (currentPage = 1, pageSize = 10) => {
    const { selectedRowKeys, formValues } = this.state;
    const { dispatch } = this.props;
    const pageArg = { currentPage, pageSize };
    let params = { pageArg: { currentPage, pageSize } };
    if (selectedRowKeys.length) {
      params = { ...params, recvAddTaskIds: selectedRowKeys };
    } else {
      params = { ...params, ...formValues };
    }
    dispatch({
      type: 'addemprec/getTaskOrinjAcc',
      payload: { ...params, pageArg },
    }).then(response => {
      if (response.success && response.data) {
        if (response.data.pageRecords && response.data.pageRecords.length) {
          this.setState({ receiveModal: true });
        } else if (response.data && !response.data.totalCount) {
          // 获取批次任务
          this.setState({ receiveModal: false });
          dispatch({
            type: 'addemprec/updateModelData',
            payload: {
              injAccList: [],
              allInjAccList: [],
            },
          });
        }
      } else {
        message.warning(response.message || '获取接单信息：服务器端错误');
      }
    });
  };

  // 表格有变化：比如：切换页码
  handleStandardTableInjAcc = pagination => {
    this.getTaskOrinjAcc(pagination.current, pagination.pageSize);
  };

  // 表格有变化：比如：切换页码
  handleStandardTableChange = pagination => {
    const { activeKey } = this.props;
    this.getList(activeKey, pagination.current, pagination.pageSize, undefined, false);
  };

  // 更改状态:废弃
  updateStatus = suppProtId => {
    const { dispatch } = this.props;
    Modal.confirm({
      icon: <QuestionCircleOutlined />,
      title: `你确定要废弃此协议吗？`,
      okText: '确认',
      cancelText: '取消',
      onOk: () => {
        dispatch({
          type: 'addemprec/updateStatus',
          payload: { suppProtId },
          callback: response => {
            if (response.success) {
              this.handleSearch();
              message.success('废弃成功！');
            } else {
              message.warning('废弃失败!');
            }
          },
        });
      },
    });
  };

  getData = (value, id) => {
    const { form } = this.props;
    if (id) {
      form.setFieldsValue({ [id]: value });
      this.setState({ [id]: value });
    }
  };

  // 关闭工伤二级户的弹框
  handleCloseReceive = () => {
    this.setState({ receiveModal: false });
    this.getList();
  };

  // 选择工伤二级户
  selectSecAcco = (value, options, key) => {
    const { dispatch, injAccList, allInjAccList } = this.props;
    if (value.length === 1) {
      message.warning(`请选择"${options[0].accoName}"的二级户`);
    }
    if (injAccList.list && injAccList.list.length) {
      const index = _.findIndex(allInjAccList, { key });
      if (index > -1) {
        allInjAccList[index].injecIdList = value;
      }
      injAccList.list.map(item => {
        if (item.key === key) {
          item.injecIdList = value;
        }
      });
      dispatch({
        type: 'addemprec/updateModelData',
        payload: {
          injAccList,
          allInjAccList,
        },
      });
    }
  };

  // 接单
  // eslint-disable-next-line consistent-return
  batchReceiveOrder = () => {
    const {
      form,
      dispatch,
      injAccList: { pagination },
      allInjAccList,
      injAccParams,
    } = this.props;
    form.validateFieldsAndScroll(err => {
      if (!err) {
        const selectInjList = allInjAccList.filter(item => item.injecIdList);
        if (selectInjList.length < pagination.total) {
          return message.warning(
            `还有${pagination.total -
              selectInjList.length}个客户未选择二级户，请全部选择完成后再接单`
          );
        }
        const dets = [];
        let isReceiveOrder = true;
        selectInjList.forEach(item => {
          if (!item.injecIdList || item.injecIdList.length !== 2) {
            isReceiveOrder = false;
            message.warning(
              `客户名称为‘${item.custName}’且签约方为‘${
                item.sendSuppName
              }’的数据选择工伤二级户有误，请重新选择`
            );
          }
          dets.push({
            cityId: item.cityId,
            custId: item.custId,
            sendSuppId: item.sendSuppId,
            taskIds: item.taskIds,
            injSecId: item.injecIdList && item.injecIdList.length === 2 && item.injecIdList[1],
          });
        });
        if (isReceiveOrder) {
          const params = {
            dets,
            ...injAccParams,
          };
          dispatch({
            type: 'addemprec/uploadFileWithProgress',
            payload: { params, isBatch: true },
          }).then(res => {
            if (res.success) {
              this.setState({ receiveModal: false });
              dispatch({
                type: 'addemprec/updateModelData',
                payload: {
                  injAccList: [],
                  allInjAccList: [],
                },
              });
            } else {
              message.warning(res.message || '接单失败！');
            }
          });
        }
      }
    });
  };

  // 关闭弹框
  closeInjAccModal = () => {
    const { dispatch } = this.props;
    dispatch({
      type: 'addemprec/updateModelData',
      payload: {
        injAccList: [],
        allInjAccList: [],
      },
    });
    this.setState({ receiveModal: false });
  };

  // 切换页签
  changeTabPane = activeKey => {
    const { tabList, dispatch, location } = this.props;
    const { editFlag } = this.state;
    router.push({
      pathname: location.pathname,
      query: {
        activeKey,
      },
    });
    tabList.map(item => {
      if (item.itemCode == activeKey) {
        item.isHas = false;
      }
    });
    this.setState({
      selectedRows: [],
      selectedRowKeys: [],
    });

    dispatch({
      type: 'addemprec/updateModelData',
      payload: {
        activeKey,
        tabList,
      },
    });
    const pageArg = { currentPage: 1, pageSize: 10 };
    const values = {
      pageArg,
      hdlState: activeKey,
      editFlag,
    };
    this.setState(
      {
        selectedRows: [],
        selectedRowKeys: [],
        formValues: values,
      },
      () => {
        this.getList(activeKey);
      }
    );
  };

  // 取消接单
  cancelReceive = () => {
    const { selectedRowKeys } = this.state;
    const { form } = this.props;
    if (selectedRowKeys.length) {
      this.setState({ cancelReceiveVisible: true });
      form.resetFields(['remark']);
    } else {
      message.warning('请至少选择一条数据！');
    }
  };

  // 提交取消回单办理备注
  submitCancelReceive = () => {
    const { dispatch, form, activeKey } = this.props;
    const { selectedRowKeys } = this.state;
    form.validateFields(['remark'], (err, values) => {
      if (!err) {
        dispatch({
          type: 'addemprec/cancelReceive',
          payload: { recvOrdAddTaskId: selectedRowKeys, remark: values.remark },
        }).then(response => {
          if (response.success) {
            this.getList(activeKey);
            this.setState({ cancelReceiveVisible: false });
            message.success('取消接单成功！');
          } else {
            message.warning(`${response.message || '取消接单失败！'}`);
          }
        });
      }
    });
  };

  // 重置查询条件并获取列表
  async resetAndGeLlist(location) {
    const { dispatch, tabList } = this.props;
    const { queryParam } = location;
    if (queryParam) {
      await dispatch({
        type: 'addemprec/updateModelData',
        payload: {
          expandForm: true,
        },
      });
    } else {
      const newTabList = tabList.map(item => ({ ...item, isHas: false }));
      dispatch({
        type: 'addemprec/updateModelData',
        payload: { expandForm: false, tabList: newTabList },
      });
    }
    await this.handleFormReset();
    await this.getList(location.query.activeKey, undefined, undefined, queryParam);
    dispatch({
      type: 'global/changeIsMenuLink',
      payload: location,
    });
  }

  renderSimpleForm() {
    const {
      form: { getFieldDecorator },
      supplyList,
      formFieldsValue,
      activeKey,
    } = this.props;
    return (
      <Form layout="inline">
        <Row gutter={{ md: 8, lg: 24, xl: 48 }}>
          <Col md={8} sm={24}>
            <FormItem label="签约方" {...this.tableSearchLayout}>
              {getFieldDecorator('sendSuppId', {
                initialValue: formFieldsValue.sendSuppId,
              })(
                // <Supplier allowClear params={{ status: 2 }} onChange={this.suppId} />
                <Select
                  placeholder="请输入关键字检索"
                  showSearch
                  optionFilterProp="children"
                  notFoundContent="暂无数据"
                  onSelect={(value, options) => this.getData(value, options)}
                  onChange={this.getsuppId}
                  allowClear
                >
                  {supplyList.map(item => (
                    <Option key={item.suppId} title={item.name}>
                      {item.name}
                    </Option>
                  ))}
                </Select>
              )}
            </FormItem>
          </Col>
          <Col md={8} sm={24}>
            <FormItem {...this.tableSearchLayout} label="执行地区">
              {getFieldDecorator('cityId', {
                initialValue: formFieldsValue.cityId,
              })(<Area allowClear labelInValue />)}
            </FormItem>
          </Col>
          <Col md={8} sm={24}>
            <span className={styles.submitButtons}>
              <Button type="primary" onClick={() => this.handleSearch(activeKey)}>
                查询
              </Button>
              <Button style={{ marginLeft: 8 }} onClick={this.handleFormReset}>
                重置
              </Button>
              <a style={{ marginLeft: 8 }} onClick={this.toggleForm}>
                展开 <DownOutlined />
              </a>
            </span>
          </Col>
        </Row>
      </Form>
    );
  }

  renderAdvancedForm() {
    const {
      form: { getFieldDecorator },
      custList,
      supplyList,
      formFieldsValue,
      activeKey,
    } = this.props;
    if (formFieldsValue.operTimeStart && formFieldsValue.operTimeEnd) {
      formFieldsValue.createTime = [];
      formFieldsValue.createTime[0] = formFieldsValue.operTimeStart;
      formFieldsValue.createTime[1] = formFieldsValue.operTimeEnd;
    }

    return (
      <Form layout="inline">
        <Row gutter={{ md: 8, lg: 24, xl: 48 }}>
          <Col md={8} sm={24}>
            <FormItem {...this.tableSearchLayout} label="签约方">
              {getFieldDecorator('sendSuppId', {
                initialValue: formFieldsValue.sendSuppId,
              })(
                <Select
                  placeholder="请输入关键字检索"
                  showSearch
                  optionFilterProp="children"
                  notFoundContent="暂无数据"
                  onSelect={(value, options) => this.getData(value, options)}
                  onChange={this.getsuppId}
                  allowClear
                >
                  {supplyList.map(item => (
                    <Option key={item.suppId} title={item.name}>
                      {item.name}
                    </Option>
                  ))}
                </Select>
              )}
            </FormItem>
          </Col>
          <Col md={8} sm={24}>
            <FormItem {...this.tableSearchLayout} label="执行地区">
              {getFieldDecorator('cityId', {
                initialValue: formFieldsValue.cityId,
              })(<Area allowClear labelInValue />)}
            </FormItem>
          </Col>
          <Col md={8} sm={24}>
            <FormItem {...this.tableSearchLayout} label="客户名称">
              {getFieldDecorator('custId', {
                rules: [{ required: false }],
                initialValue: formFieldsValue.custId,
              })(
                <Select placeholder="请选择" showSearch optionFilterProp="children" allowClear>
                  {custList &&
                    custList.map(one => (
                      <Option key={one.custId} value={one.custId} title={one.name}>
                        {one.name}
                      </Option>
                    ))}
                </Select>
              )}
            </FormItem>
          </Col>
        </Row>
        <Row gutter={{ md: 8, lg: 24, xl: 48 }}>
          <Col md={8} sm={24}>
            <FormItem {...this.tableSearchLayout} label="姓名">
              {getFieldDecorator('empName', {
                rules: [{ required: false }],
                initialValue: formFieldsValue.empName,
              })(<Input placeholder="请输入" />)}
            </FormItem>
          </Col>
          <Col md={8} sm={24}>
            <FormItem label="证件号" {...this.tableSearchLayout}>
              {getFieldDecorator('idCode', {
                initialValue: formFieldsValue.idCode,
              })(<Input placeholder="请输入" />)}
            </FormItem>
          </Col>
          <Col md={8} sm={24}>
            <FormItem label="操作时间" {...this.tableSearchLayout}>
              {getFieldDecorator('createTime', {
                initialValue: formFieldsValue.createTime,
              })(
                <RangePicker
                  placeholder={['开始日期', '结束日期']}
                  style={{ width: '100%' }}
                  format="YYYY-MM-DD"
                />
              )}
            </FormItem>
          </Col>
        </Row>
        <Row gutter={{ md: 8, lg: 24, xl: 48 }}>
          <Col md={8} sm={24} />
          <Col md={8} sm={24} />
          <Col md={8} sm={24}>
            <div style={{ overflow: 'hidden' }}>
              <div style={{ float: 'right', marginBottom: 16 }}>
                <Button type="primary" onClick={() => this.handleSearch(activeKey)}>
                  查询
                </Button>
                <Button style={{ marginLeft: 8 }} onClick={this.handleFormReset}>
                  重置
                </Button>
                <a style={{ marginLeft: 8 }} onClick={this.toggleForm}>
                  收起
                  <UpOutlined />
                </a>
              </div>
            </div>
          </Col>
        </Row>
      </Form>
    );
  }

  renderForm() {
    const { expandForm } = this.props;
    return expandForm ? this.renderAdvancedForm() : this.renderSimpleForm();
  }

  render() {
    const {
      data,
      loading,
      activeKey,
      form: { getFieldDecorator },
      cancelReceiveLoading,
      addemprec,
      injAccList,
      // proData,
      downloadParams,
    } = this.props;
    const { selectedRows, selectedRowKeys, cancelReceiveVisible, receiveModal } = this.state;
    const formItemLayout = {
      labelCol: { md: { span: 7 } },
      wrapperCol: { md: { span: 16 } },
    };
    const moreMenu = (
      <Menu>
        {checkPermissions('ns:recvAdd:exportRecvd') && (
          <Menu.Item
            key="export"
            onClick={() => {
              this.export();
            }}
          >
            导出
          </Menu.Item>
        )}
        {checkPermissions('ns:recvAdd:batch:return') && (
          <Menu.Item
            key="batchreplied"
            onClick={() => router.push(`/receiveordermanage/addemployee/batchreplied`)}
          >
            批量回单
          </Menu.Item>
        )}
        {checkPermissions('ns:recvProb:privSupp:addProb') && (
          <Menu.Item
            key="remarkProb"
            onClick={() => {
              this.showModal(true);
            }}
          >
            标记问题人员
          </Menu.Item>
        )}
        {checkPermissions('ns:recvAdd:cancelRecv') && (
          <Menu.Item key="cancelReceive" onClick={this.cancelReceive}>
            取消接单
          </Menu.Item>
        )}
      </Menu>
    );
    // 待接单
    const customerCharge = (
      <div>
        <Row style={{ marginBottom: '16px' }}>
          <Col md={12} sm={24}>
            <Authorized authority="ns:recvAdd:recvOrd" noMatch={null}>
              <Button
                type="primary"
                style={{ marginRight: '8px' }}
                onClick={() => {
                  this.receiveOrder();
                }}
                disabled={data.list && !data.list.length}
              >
                接单
              </Button>
            </Authorized>
            <Authorized authority="ns:rcvrAddProb:addProb" noMatch={null}>
              <Button
                onClick={() => {
                  this.showModal(true);
                }}
              >
                标记问题人员
              </Button>
            </Authorized>
            {data.countVo && (
              <div style={{ margin: '16px 16px 0 0	', width: '200%' }}>
                <Alert
                  message={
                    <Fragment>
                      客户数量
                      <a style={{ margin: '0 20px' }}>
                        {data.countVo ? data.countVo.custAmount : null}
                      </a>
                      员工数量
                      <a style={{ margin: '0 20px' }}>
                        {data.countVo ? data.countVo.empAmount : null}
                      </a>
                      {data.countVo && data.countVo.empAmount !== 0 ? (
                        <Link to="/receiveordermanage/addemployee/detailprots">查看协议</Link>
                      ) : null}
                    </Fragment>
                  }
                  type="info"
                  showIcon
                />
              </div>
            )}
          </Col>
        </Row>
        <StandardTable
          selectedRows={selectedRows}
          selectedRowKeys={selectedRowKeys}
          loading={loading}
          data={data}
          rowKey="recvOrdAddTaskId"
          columns={this.columns}
          onSelectRow={this.handleSelectRows}
          onChange={this.handleStandardTableChange}
        />
      </div>
    );
    // 已接单
    const employeeCharge = (
      <div>
        <Row style={{ marginBottom: 16 }}>
          <Authorized authority="ns:recvAdd:getEmpContact" noMatch={null}>
            <Button
              type="primary"
              style={{ marginRight: '8px' }}
              onClick={() => {
                this.employeecontact();
              }}
            >
              员工联系
            </Button>
          </Authorized>
          <Authorized authority="ns:recvAdd:detail" noMatch={null}>
            <Button style={{ marginRight: '8px' }} onClick={() => this.orderreceipt(2)}>
              回单
            </Button>
          </Authorized>
          <Dropdown overlay={moreMenu}>
            <Button>
              更多
              <DownOutlined />
            </Button>
          </Dropdown>
        </Row>
        <StandardTable
          selectedRows={selectedRows}
          selectedRowKeys={selectedRowKeys}
          loading={loading}
          data={data}
          rowKey="recvOrdAddTaskId"
          columns={this.columnstwo}
          onSelectRow={this.handleSelectRows}
          onChange={this.handleStandardTableChange}
        />
      </div>
    );
    // 已回单
    const supplierCharge = (
      <div>
        <div style={{ marginBottom: '16px' }}>
          <Authorized authority="ns:recvAdd:exportRecvd" noMatch={null}>
            <Button type="primary" icon={<DownloadOutlined />} onClick={this.export}>
              导出
            </Button>
          </Authorized>
          <div style={{ float: 'right' }}>
            <RadioGroup
              className={styles.floatRight}
              // eslint-disable-next-line react/destructuring-assignment
              value={this.state.editFlag}
              onChange={this.saculo}
            >
              <RadioButton value={null}>全部</RadioButton>
              <RadioButton value={2}>无修改</RadioButton>
              <RadioButton value={1}>有修改</RadioButton>
            </RadioGroup>
          </div>
        </div>
        <StandardTable
          selectedRowKeys={selectedRowKeys}
          selectedRows={selectedRows}
          loading={loading}
          data={data}
          rowKey="recvOrdAddTaskId"
          columns={this.columnsthree}
          onSelectRow={this.handleSelectRows}
          onChange={this.handleStandardTableChange}
        />
      </div>
    );
    // 问题人员
    const problemPeople = (
      <div>
        <div style={{ marginBottom: 16 }}>
          <Authorized noMatch={null} authority="ns:rcvrAddProb:addProbFdbk">
            <Button
              type="primary"
              onClick={() =>
                router.push('/receiveordermanage/addemployee/batchfeedback?busiType=8')
              }
              style={{ marginRight: 8 }}
            >
              批量反馈
            </Button>
          </Authorized>
          {/* <Authorized authority="ns:recvProb:sendSupp:notice" noMatch={null}>
          <Button
            style={{ margin: '0 8px 16px 0' }}
            onClick={() => {
              this.notifycontg();
            }}
          >
            通知签约方
          </Button>
        </Authorized> */}
          <Authorized noMatch={null}>
            <ProExportBtn selectedRowKeys={selectedRowKeys} downloadParams={downloadParams} />
          </Authorized>
        </div>
        <ProTable
          onRef={e => {
            this.setState({ proTable: e });
          }}
          selectedRows={selectedRows}
          selectedRowKeys={selectedRowKeys}
          onSelectRow={this.handleSelectRows}
          proUrl="/receiveordermanage/addemployee/problem"
          busiType="8"
        />
      </div>
    );
    // 已取消
    const canCelled = (
      <div>
        <StandardTable
          selectedRows={selectedRows}
          selectedRowKeys={selectedRowKeys}
          loading={loading}
          data={data}
          rowKey="recvOrdAddTaskId"
          columns={this.columnsfive}
          onSelectRow={this.handleSelectRows}
          onChange={this.handleStandardTableChange}
        />
      </div>
    );
    // 设置工伤二级户
    const secondaryCloumns = [
      {
        title: '客户名称',
        dataIndex: 'custName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
      },
      {
        title: '签约方',
        dataIndex: 'sendSuppName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
      },
      {
        title: '工伤二级户',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        width: 400,
        render: (text, record) => (
          <FormItem style={{ margin: 0 }}>
            {getFieldDecorator(`secondary[${record.key}]`, {
              rules: [{ required: true, message: '请选择' }],
              initialValue: record.injecIdList || undefined,
            })(
              <Cascader
                allowClear={false}
                placeholder="请选择"
                options={record.injAccInfo}
                showSearch
                notFoundContent="暂无工伤二级户"
                onChange={(value, options) => this.selectSecAcco(value, options, record.key)}
                changeOnSelect
                style={{ width: 400 }}
              />
            )}
          </FormItem>
        ),
      },
    ];

    // 获取页签组件
    const getTabPane = activeKeys => {
      if (activeKeys == 1) {
        return customerCharge;
      }
      if (activeKeys == 2) {
        return employeeCharge;
      }
      if (activeKeys == 3) {
        return supplierCharge;
      }
      if (activeKeys == 4) {
        return problemPeople;
      }
      if (activeKeys == 5) {
        return canCelled;
      }
      return <div />;
    };
    const { tabList } = this.props;
    const { proVisible } = this.state;
    return (
      <PageHeaderWrapper>
        <Card className={styles.searchCard} bordered={false}>
          <div className={styles.tableListForm}>{this.renderForm()}</div>
        </Card>
        <Card className={styles.tabCard}>
          <div className={styles.tableList}>
            <Tabs activeKey={activeKey} onChange={this.changeTabPane}>
              {tabList.map(pane => (
                <TabPane tab={<Badge dot={pane.isHas}>{pane.itemName}</Badge>} key={pane.itemCode}>
                  {getTabPane(pane.itemCode)}
                </TabPane>
              ))}
            </Tabs>
          </div>
        </Card>
        {proVisible && (
          <ProModal
            selectedRows={selectedRows}
            selectedRowKeys={selectedRowKeys}
            busiType="8"
            onOk={this.proHandleOk}
            onCancel={() => this.toggleProModal(false)}
            isProObj
          />
        )}
        <Modal
          title="设置工伤二级户"
          visible={receiveModal}
          width={1200}
          onCancel={this.closeInjAccModal}
          destroyOnClose
          footer={
            <Button type="primary" onClick={() => this.batchReceiveOrder()}>
              接单
            </Button>
          }
        >
          <StandardTable
            selectedRows={[]}
            selectedRowKeys={[]}
            loading={loading}
            data={injAccList}
            rowKey="key"
            columns={secondaryCloumns}
            rowSelection={null}
            onChange={this.handleStandardTableInjAcc}
            className={styles.errorMsg}
          />
        </Modal>
        <Modal
          title="取消接单"
          destroyOnClose
          visible={cancelReceiveVisible}
          onOk={this.submitCancelReceive}
          onCancel={() => this.setState({ cancelReceiveVisible: false })}
          confirmLoading={cancelReceiveLoading}
        >
          <FormItem {...formItemLayout} label="办理备注">
            {getFieldDecorator('remark', {
              rules: [{ required: cancelReceiveVisible, message: '请输入' }],
            })(
              <TextArea
                placeholder="请输入"
                autosize={{ minRows: 3, maxRows: 6 }}
                maxLength="100"
              />
            )}
          </FormItem>
        </Modal>
        <BatchTaskProgress
          progressVisible={addemprec.showProgress}
          progressPercent={addemprec.progressPercent || 0}
          isShowResult={addemprec.progressPercent === 100}
          resultInfo={addemprec.resultInfo}
          checkHasTask={this.checkHasTask}
          handleProgressModalVisible={this.handleProgressModalVisible}
          maskClosable={false}
        />
      </PageHeaderWrapper>
    );
  }
}

export default TableList;
